package com.anlen.sign;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;

public class MainActivity extends BaseActivity {


		EditText username;
		EditText password;
		Button login;
		CheckBox check;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);

			username = (EditText) findViewById(R.id.username);
			password = (EditText) findViewById(R.id.password);
			check = (CheckBox) findViewById(R.id.checkBox1);
			
			
			SharedPreferences sp=getSharedPreferences("config", Context.MODE_PRIVATE);
			username.setText(sp.getString("username", ""));
			password.setText(sp.getString("password", ""));
		}
		
		public void login(View view){
			String names;
			String passwords;
			names = username.getText().toString().trim();
			passwords = password.getText().toString().trim();
			if(TextUtils.isEmpty(names)||TextUtils.isEmpty(passwords)){
				super.showToast("账号或者密码不能为空");
			}
				
			if(check.isChecked()){
				
				SharePreferenceService.saveInfo(this, names, passwords);
				super.showToast("保存信息到本地文件中，下次登录就会显示上次登录的信息");
			}
		}
		
}

